<?php
//require_once("admin-header.php");
require_once("../include/db_info.inc.php");
require_once ("../include/my_func.inc.php");
;?>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<!--<link rel=stylesheet href='../include/hoj.css' type='text/css'>-->
<script src="../template/bs3/jquery.min.js"></script>
<script>
    $("document").ready(function (){
        $("form").append("<div id='csrf' />");
        $("#csrf").load("../csrf.php");
    });

</script>
<?php if (!(isset($_SESSION[$OJ_NAME.'_'.'administrator'])||isset($_SESSION[$OJ_NAME.'_'.'contest_creator'])||isset($_SESSION[$OJ_NAME.'_'.'problem_editor'])||isset($_SESSION[$OJ_NAME.'_'.'password_setter']))){
    echo "<a href='../loginpage.php'>请先登录！</a>";
    exit(1);
}
//require_once("../template/$OJ_TEMPLATE/css.php");
if(file_exists("../lang/$OJ_LANG.php")) require_once("../lang/$OJ_LANG.php");

  if(isset($OJ_LANG)){
    require_once("../lang/$OJ_LANG.php");
  }
  $path_fix="../";
  $OJ_TEMPLATE="bs3";
?>
<html>
<head>
<title><?php echo $MSG_ADMIN?></title>

<!-- 这个css定义了一些全局样式，不太行-->
<!--<link rel="stylesheet" href="--><?php //echo $OJ_CDN_URL.$path_fix."template/$OJ_TEMPLATE/"?><!--bootstrap-theme.min.css">-->
<!-- jQuery文件。务必在bootstrap.min.js 之前引入 -->
<script src="<?php echo $OJ_CDN_URL.$path_fix."template/$OJ_TEMPLATE/"?>jquery.min.js"></script>

<!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
<script src="<?php echo $OJ_CDN_URL.$path_fix."template/$OJ_TEMPLATE/"?>bootstrap.min.js"></script>

    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <!-- 引入 Bootstrap -->
    <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">


    <style type="text/css">
        a,a:hover,a:focus{
            color: #ffffff;
            text-decoration: none;
        }
        .panel-group {
            background-color: #404040;
            /*width: 250px;*/
            /*height: 600px;*/
            overflow-y: auto;
        }
        .panel-group .panel {
            background-color: #404040;
            border: none;
        }

        .panel-heading{
            border-top-left-radius: 0px;
            border-top-right-radius: 0px;
        }
        .panel-default>.panel-heading {
            border: none;
            color: #ffffff;
            background-color: #505050;
        }
        .panel-default>.panel-heading>span{
            font-size: 10px;
        }
        .panel-default>.panel-heading:active,.panel-default>.panel-heading:hover{
            background-color: #4a8bc2;
        }
        .panel-default>.panel-heading>a:hover{
            text-decoration: none;
            background-color: #4a8bc2;
        }
        .panel-group .panel-heading+.panel-collapse>.panel-body {
            border: none;
        }
        .panel-body {
            padding: 0px;
        }
        .nav>li{
            padding: 1px 0px 0px 0px;
        }
        .nav>li>a{
            text-decoration: none;
            padding: 10px 10px 10px 35px;
        }
        .nav>li>a:hover,.nav>li>a:focus{
            background-color: #505050;
        }

    </style>
<!--    原文链接：https://blog.csdn.net/jinxiumeihappy/article/details/78541868-->
</head>

<body style="background-color:#404040">
<!--<hr>-->
<a class='btn btn-block btn' style="font-size: 20px;color: #FFFFFF" href="help.php" target="main" title="<?php echo $MSG_ADMIN?>"><b>Verilog判题平台后台管理</b></a>
<!--<hr>-->
<!---->
<a class='btn btn-block btn' style="font-size: 16px;color: #FFFFFF" href="../status.php" target="_top" title="<?php echo $MSG_HELP_SEEOJ?>"><b><?php echo $MSG_SEEOJ?></b></a><br>

<!--<a class='btn btn-block btn-sm' href="help.php" target="main" title="--><?php //echo $MSG_ADMIN?><!--"><b>--><?php //echo $MSG_ADMIN?><!--</b></a>-->

<!--    新导航栏-->
<?php if (isset($_SESSION[$OJ_NAME.'_'.'administrator'])||isset( $_SESSION[$OJ_NAME.'_'.'password_setter'])){?>
<div class="panel-group" id="panelContainer1">
    <div class="panel panel-default">
        <div id="header1" class="panel-heading" data-toggle="collapse" data-target="#sub1" data-parent="#panelContainer1">
            <i class="glyphicon glyphicon-user"></i>
            <a href="#">用户管理</a>
            <span class="glyphicon glyphicon-triangle-right pull-right"></span>
        </div>
        <div id="sub1" class="collapse panel-collapse">
            <div class="panel-body">
                <ul class="nav">
                    <?php if (isset($_SESSION[$OJ_NAME.'_'.'administrator'])||isset( $_SESSION[$OJ_NAME.'_'.'password_setter'])){?>
                    <li>
                        <a href="user_list.php" target="main">用户列表</a>
                    </li>
                    <?php }?>
                    <?php if (isset($_SESSION[$OJ_NAME.'_'.'administrator'])){?>
                    <li>
                        <a href="user_add.php" target="main">添加用户</a>
                    </li>
                    <?php }?>
                    <?php if (isset($_SESSION[$OJ_NAME.'_'.'administrator'])||isset( $_SESSION[$OJ_NAME.'_'.'password_setter'])){?>
                    <li>
                        <a href="changepass.php" target="main">修改用户密码</a>
                    </li>
                    <?php }?>
                    <?php if (isset($_SESSION[$OJ_NAME.'_'.'administrator'])){?>
                    <li>
                        <a href="privilege_list.php" target="main">用户权限列表</a>
                    </li>
                    <li>
                        <a href="privilege_add.php" target="main">添加用户权限</a>
                    </li>
                    <?php }?>
                </ul>
            </div>
        </div>
    </div>
</div>
<?php }?>

<?php if (isset($_SESSION[$OJ_NAME.'_'.'administrator'])||isset($_SESSION[$OJ_NAME.'_'.'problem_editor'])||isset($_SESSION[$OJ_NAME.'_'.'contest_creator'])) {?>
<div class="panel-group" id="panelContainer2">
    <div class="panel panel-default">
        <div id="header2" class="panel-heading" data-toggle="collapse" data-target="#sub2" data-parent="#panelContainer2">
            <i class="glyphicon glyphicon-list-alt"></i>
            <a href="#">题目管理</a>
            <span class="glyphicon glyphicon-triangle-right pull-right"></span>
        </div>
        <div id="sub2" class="collapse panel-collapse">
            <div class="panel-body">
                <ul class="nav">
                    <?php if (isset($_SESSION[$OJ_NAME.'_'.'administrator'])||isset($_SESSION[$OJ_NAME.'_'.'problem_editor'])||isset($_SESSION[$OJ_NAME.'_'.'contest_creator'])) {?>
                    <li>
                        <a href="problem_list.php" target="main">题目列表</a>
                    </li>
                    <?php }
                    if (isset($_SESSION[$OJ_NAME.'_'.'administrator'])||isset($_SESSION[$OJ_NAME.'_'.'problem_editor'])) {?>
                    <li>
                        <a href="problem_add_page.php" target="main">添加题目</a>
                    </li>
                    <?php }?>
                </ul>
            </div>
        </div>
    </div>
</div>
<?php }?>

<?php if (isset($_SESSION[$OJ_NAME.'_'.'administrator'])||isset($_SESSION[$OJ_NAME.'_'.'contest_creator'])){?>
<div class="panel-group" id="panelContainer3">
    <div class="panel panel-default">
        <div id="header3" class="panel-heading" data-toggle="collapse" data-target="#sub3" data-parent="#panelContainer3">
            <i class="glyphicon glyphicon-book"></i>
            <a href="#">作业管理</a>
            <span class="glyphicon glyphicon-triangle-right pull-right"></span>
        </div>
        <div id="sub3" class="collapse panel-collapse">
            <div class="panel-body">
                <ul class="nav">
                    <?php if (isset($_SESSION[$OJ_NAME.'_'.'administrator'])||isset($_SESSION[$OJ_NAME.'_'.'contest_creator'])){?>
                    <li>
                        <a href="contest_list.php" target="main">作业列表</a>
                    </li>
                    <li>
                        <a href="contest_add.php" target="main">添加作业</a>
                    </li>
                    <li>
                        <a href="team_generate2.php" target="main">学生账号生成</a>
                    </li>
                    <?php }?>
                </ul>
            </div>
        </div>
    </div>
</div>
<?php }?>

<?php if (isset($_SESSION[$OJ_NAME.'_'.'administrator'])){?>
<div class="panel-group" id="panelContainer4">
    <div class="panel panel-default">
        <div id="header4" class="panel-heading" data-toggle="collapse" data-target="#sub4" data-parent="#panelContainer4">
            <i class="glyphicon glyphicon-cog"></i>
            <a href="#">系统管理</a>
            <span class="glyphicon glyphicon-triangle-right pull-right"></span>
        </div>
        <div id="sub4" class="collapse panel-collapse">
            <div class="panel-body">
                <ul class="nav">
                    <li>
                        <a href="rejudge.php" target="main">重判题目</a>
                    </li>
                    <li>
                        <a href="../online.php" target="main">查看在线用户</a>
                    </li>
                </ul>
            </div>
        </div>
    </div>
</div>
<?php }?>

<!--
<?php if (isset($_SESSION[$OJ_NAME.'_'.'administrator'])){?>
  <br><a class='btn btn-block btn-sm' href="https://github.com/zhblue/hustoj/" target="_blank"><b>HUSTOJ</b></a>
  <br><center><a class="btn btn-sm" target='_blank' href="https://github.com/zhblue/hustoj/blob/master/wiki/FAQ.md"><?php echo $MSG_ADMIN." ".$MSG_FAQ?></a></center>
  <br><a class='btn btn-block btn-sm' href="https://github.com/zhblue/freeproblemset/" target="_blank"><b>FreeProblemSet</b></a>
  <br><a class='btn btn-block btn-sm' href="http://tk.hustoj.com" target="_blank"><b>自助题库</b></a>
  <br><a class='btn btn-block btn-sm' href="http://shang.qq.com/wpa/qunwpa?idkey=d52c3b12ddaffb43420d308d39118fafe5313e271769277a5ac49a6fae63cf7a" target="_blank">手机QQ加官方<br>群23361372</a>
<?php }?>

<?php if (isset($_SESSION[$OJ_NAME.'_'.'administrator'])&&!$OJ_SAE){?>
  <a href="problem_copy.php" target="main" title="Create your own data"><font color="eeeeee">CopyProblem</font></a> <br>
  <a href="problem_changeid.php" target="main" title="Danger,Use it on your own risk"><font color="eeeeee">ReOrderProblem</font></a>
<?php }?>

-->

<script>
    $(function() {
        $(".panel-heading").on("click", function(e) {
            var idLength = e.currentTarget.id.length;
            var index = e.currentTarget.id.substr(idLength - 1, idLength);
            //控制箭头显示
            $("#sub" + index).on('hidden.bs.collapse', function() {
                $(e.currentTarget).find("span").removeClass("glyphicon glyphicon-triangle-bottom");
                $(e.currentTarget).find("span").addClass("glyphicon glyphicon-triangle-right");
            })
            $("#sub" + index).on('shown.bs.collapse', function() {
                $(e.currentTarget).find("span").removeClass("glyphicon glyphicon-triangle-right");
                $(e.currentTarget).find("span").addClass("glyphicon glyphicon-triangle-bottom");
            })
        })

        $(".panel-body > .nav > li > a").on("click", function(e) {
            // alert(e.currentTarget.textContent);
        });
    });
</script>
</body>
</html>
